# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=ruby-async-rspec
pkgver=1.16.1
pkgrel=2
pkgdesc='Helpers for writing specs against the async gem'
arch=(any)
url='https://github.com/socketry/async-rspec'
license=(MIT)
depends=(ruby-rspec ruby-rspec-files ruby-rspec-memory)
checkdepends=(ruby-async ruby-async-io ruby-covered)
options=(!emptydirs)
source=(https://github.com/socketry/async-rspec/archive/v$pkgver/$pkgname-$pkgver.tar.gz)
sha256sums=('9635688bef6be7922363620a41d9c64f60ff6537af3ac83106a29947800b9cd3')

prepare() {
  cd async-rspec-$pkgver
  sed -r -e 's|~>|>=|g' -i async-rspec.gemspec
}

build() {
  local _gemdir="$(gem env gemdir)"
  cd async-rspec-$pkgver
  gem build async-rspec.gemspec
  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "tmp_install/$_gemdir" \
    --bindir "tmp_install/usr/bin" \
    async-rspec-$pkgver.gem
  find "tmp_install/$_gemdir/gems/" \
    -type f \
    \( \
        -iname "*.o" -o \
        -iname "*.c" -o \
        -iname "*.so" -o \
        -iname "*.time" -o \
        -iname "gem.build_complete" -o \
        -iname "Makefile" \
    \) \
    -delete
  rm -r tmp_install/$_gemdir/cache
}

check() {
  local _gemdir="$(gem env gemdir)"
  cd async-rspec-$pkgver
  GEM_HOME="tmp_install/$_gemdir" rspec
}

package() {
  cd async-rspec-$pkgver
  cp -a tmp_install/* "$pkgdir"/
}
